
import { createRouter, createWebHistory } from "vue-router";
import AppLayout from "@/layout/AppLayout.vue";
import MainContent from "@/views/MainContent.vue";


const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/login/LoginView.vue"),
      meta: {
        title: "登录",
      }
    },
    {
      path: "/",
      name: "",
      redirect: "/login",
      component: AppLayout,
      children: [
        {
          path: "/home",
          name: "home",
          component: MainContent,
          meta: {
            title: "首页",
            requiresAuth: true,
          }
        },
        {
          path: "/center",
          name: "center",
          component: () => import("@/views/center/CenterView.vue"),
          meta: {
            title: "个人中心",
          }
        },
        {
          path: "/addUser",
          name: "addUser",
          component: () => import("@/views/user/AddUser.vue"),
          meta: {
            title: "添加用户",
          }
        },
        {
          path: "/userList",
          name: "userList",
          component: () => import("@/views/user/UserList.vue"),
          meta: {
            title: "用户列表",
          }
        },
        {
          path: "/createNews",
          name: "createNews",
          component: () => import("@/views/news/CreateNews.vue"),
          meta: {
            title: "创建新闻",
          }
        },
        {
          path: "/newsList",
          name: "newsList",
          component: () => import("@/views/news/NewsList.vue"),
          meta: {
            title: "新闻列表",
          }
        },
        {
          path: "/addProduct",
          name: "addProduct",
          component: () => import("@/views/product/AddProduct.vue"),
          meta: {
            title: "添加商品",
          }
        },
        {
          path: "/productList",
          name: "productList",
          component: () => import("@/views/product/ProductList.vue"),
          meta: {
            title: "商品列表",
          }
        },
      ],
    },
   
  ],
}); 


export default router;